using com.byt.suce.db.dao;
using System;
using System.Data;
using System.Data.Common;
using com.byt.webcore;
using System.Collections.Generic;
using MYLSOFT.JsonSimple;
using System.Data.SqlClient;

namespace com.byt.suce.db.mapper {

    public class PkgSubsanacion : AbstractDataAccessObject , IPkgSubsanacion {

        public PkgSubsanacion() {
        }

        public PkgSubsanacion.CancelarParam cancelar(Connection conn, Dictionary<string, string> map) {
            PkgSubsanacion.CancelarParam param = newCancelarParam(map);
            cancelar(conn, param);
            return param;
        }

        public PkgSubsanacion.CancelarParam cancelar(Connection conn, JSONObject json) {
            PkgSubsanacion.CancelarParam param = newCancelarParam(json);
            cancelar(conn, param);
            return param;
        }

        public PkgSubsanacion.CancelarParam cancelar(Connection conn) {
            PkgSubsanacion.CancelarParam param = newCancelarParam();
            cancelar(conn, param);
            return param;
        }

        public void cancelar(Connection conn, PkgSubsanacion.CancelarParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].SUB_cancelar";
            DbParameter par = null;
            // idsubsanacion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsubsanacion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsubsanacion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsubsanacion;
            cmd.ExecuteNonQuery();
        }

        public PkgSubsanacion.CrearParam crear(Connection conn, Dictionary<string, string> map) {
            PkgSubsanacion.CrearParam param = newCrearParam(map);
            crear(conn, param);
            return param;
        }

        public PkgSubsanacion.CrearParam crear(Connection conn, JSONObject json) {
            PkgSubsanacion.CrearParam param = newCrearParam(json);
            crear(conn, param);
            return param;
        }

        public PkgSubsanacion.CrearParam crear(Connection conn) {
            PkgSubsanacion.CrearParam param = newCrearParam();
            crear(conn, param);
            return param;
        }

        public void crear(Connection conn, PkgSubsanacion.CrearParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].SUB_crear";
            DbParameter par = null;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;
            // idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;
            // cur_out
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@cur_out";
            par.Direction = ParameterDirection.InputOutput;
            par.DbType = DbType.Object;
            par.Value = DBNull.Value;
            DataSet ds = new DataSet();
            DataAdapter da = new SqlDataAdapter((SqlCommand)cmd);
            da.Fill(ds);
            param.CurOut = (DbDataReader)ds.Tables[0].CreateDataReader();
        }

        public PkgSubsanacion.RegistrarrespuestaParam registrarrespuesta(Connection conn, Dictionary<string, string> map) {
            PkgSubsanacion.RegistrarrespuestaParam param = newRegistrarrespuestaParam(map);
            registrarrespuesta(conn, param);
            return param;
        }

        public PkgSubsanacion.RegistrarrespuestaParam registrarrespuesta(Connection conn, JSONObject json) {
            PkgSubsanacion.RegistrarrespuestaParam param = newRegistrarrespuestaParam(json);
            registrarrespuesta(conn, param);
            return param;
        }

        public PkgSubsanacion.RegistrarrespuestaParam registrarrespuesta(Connection conn) {
            PkgSubsanacion.RegistrarrespuestaParam param = newRegistrarrespuestaParam();
            registrarrespuesta(conn, param);
            return param;
        }

        public void registrarrespuesta(Connection conn, PkgSubsanacion.RegistrarrespuestaParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].SUB_RegistrarRespuesta";
            DbParameter par = null;
            // idnotificacion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idnotificacion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idnotificacion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idnotificacion;
            // fecha
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@fecha";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.DateTime;
            if (param.Fecha == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Fecha;
            // respuesta
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@respuesta";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 4000;
            if (string.IsNullOrEmpty(param.Respuesta))
                par.Value = DBNull.Value;
            else
                par.Value = param.Respuesta;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;

            // docnumero
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@docnumero";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.String;
            par.Size = 15;
            if (string.IsNullOrEmpty(param.Numorden))
                par.Value = DBNull.Value;
            else
                par.Value = param.Numorden;

            cmd.ExecuteNonQuery();
        }

        public PkgSubsanacion.VerificarParam verificar(Connection conn, Dictionary<string, string> map) {
            PkgSubsanacion.VerificarParam param = newVerificarParam(map);
            verificar(conn, param);
            return param;
        }

        public PkgSubsanacion.VerificarParam verificar(Connection conn, JSONObject json) {
            PkgSubsanacion.VerificarParam param = newVerificarParam(json);
            verificar(conn, param);
            return param;
        }

        public PkgSubsanacion.VerificarParam verificar(Connection conn) {
            PkgSubsanacion.VerificarParam param = newVerificarParam();
            verificar(conn, param);
            return param;
        }

        public void verificar(Connection conn, PkgSubsanacion.VerificarParam param) {
            DbCommand cmd = conn.CreateCommand();
            cmd.CommandType = CommandType.StoredProcedure;
            cmd.CommandText = "[dbo].SUB_verificar";
            DbParameter par = null;
            // idsolicitud
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idsolicitud";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idsolicitud == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idsolicitud;
            // idversion
            par = cmd.CreateParameter();
            cmd.Parameters.Add(par);
            par.ParameterName = "@idversion";
            par.Direction = ParameterDirection.Input;
            par.DbType = DbType.Int32;
            if (param.Idversion == null)
                par.Value = DBNull.Value;
            else
                par.Value = param.Idversion;
            cmd.ExecuteNonQuery();
        }

        public PkgSubsanacion.CancelarParam newCancelarParam() {
            return new CancelarParam();
        }

        public PkgSubsanacion.CancelarParam newCancelarParam(Dictionary<string, string> map) {
            return new CancelarParam(map);
        }

        public PkgSubsanacion.CancelarParam newCancelarParam(JSONObject json) {
            return new CancelarParam(json);
        }

        public PkgSubsanacion.CrearParam newCrearParam() {
            return new CrearParam();
        }

        public PkgSubsanacion.CrearParam newCrearParam(Dictionary<string, string> map) {
            return new CrearParam(map);
        }

        public PkgSubsanacion.CrearParam newCrearParam(JSONObject json) {
            return new CrearParam(json);
        }

        public PkgSubsanacion.RegistrarrespuestaParam newRegistrarrespuestaParam() {
            return new RegistrarrespuestaParam();
        }

        public PkgSubsanacion.RegistrarrespuestaParam newRegistrarrespuestaParam(Dictionary<string, string> map) {
            return new RegistrarrespuestaParam(map);
        }

        public PkgSubsanacion.RegistrarrespuestaParam newRegistrarrespuestaParam(JSONObject json) {
            return new RegistrarrespuestaParam(json);
        }

        public PkgSubsanacion.VerificarParam newVerificarParam() {
            return new VerificarParam();
        }

        public PkgSubsanacion.VerificarParam newVerificarParam(Dictionary<string, string> map) {
            return new VerificarParam(map);
        }

        public PkgSubsanacion.VerificarParam newVerificarParam(JSONObject json) {
            return new VerificarParam(json);
        }

        public class CancelarParam {

            private int? idsubsanacion;

            public CancelarParam() {
            }

            public CancelarParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public CancelarParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idsubsanacion {
                get { return idsubsanacion; }
                set { this.idsubsanacion = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class CrearParam {

            private int? idsolicitud;
            private int? idversion;
            private DbDataReader curOut;

            public CrearParam() {
            }

            public CrearParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public CrearParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idsolicitud {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public int? Idversion {
                get { return idversion; }
                set { this.idversion = value; }
            }

            public DbDataReader CurOut {
                get { return curOut; }
                set { this.curOut = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class RegistrarrespuestaParam {

            private int? idnotificacion;
            private DateTime? fecha;
            private string respuesta;
            private int? idsolicitud;
            private string numorden;

            public RegistrarrespuestaParam() {
            }

            public RegistrarrespuestaParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public RegistrarrespuestaParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idnotificacion {
                get { return idnotificacion; }
                set { this.idnotificacion = value; }
            }

            public DateTime? Fecha {
                get { return fecha; }
                set { this.fecha = value; }
            }

            public string Respuesta {
                get { return respuesta; }
                set { this.respuesta = value; }
            }

            public int? Idsolicitud {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public string Numorden
            {
                get { return numorden; }
                set { this.numorden = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

        public class VerificarParam {

            private int? idsolicitud;
            private int? idversion;

            public VerificarParam() {
            }

            public VerificarParam(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public VerificarParam(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

            public int? Idsolicitud {
                get { return idsolicitud; }
                set { this.idsolicitud = value; }
            }

            public int? Idversion {
                get { return idversion; }
                set { this.idversion = value; }
            }

            public void setValuesFromMap(Dictionary<string, string> map) {
                ResourceManager.populateDtoFromMap(this, map);
            }

            public void setValuesFromMap(JSONObject json) {
                ResourceManager.populateDtoFromMap(this, json);
            }

        }

    }
}
